﻿using Alipay.AopSdk.Core.Domain;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Domain.BasicsDatum;
using SmartWMS.Domain.BusinessManage;
using SmartWMS.Domain.FinanceManage;
using SmartWMS.Server.BusinessServer.SalesReturnServer;
using SmartWMS.Server.BusinessServer.SalesReturnServer.Dto;

namespace SmartWMS.API.Controllers.BusinessMange
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "Business")]
    public class SalesReturnsController : ControllerBase
    {

        private readonly ISalesReturnServers _salesReturnServers;

        public SalesReturnsController(ISalesReturnServers salesReturnServers)
        {
            _salesReturnServers = salesReturnServers;
        }

        /// <summary>
        /// 显示销售退货
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<List<SalesReturnDtoPes>>> GetSalesReturnDtoPes(SalesReturnPage dto)
        {
            try
            {
                var list = await _salesReturnServers.GetSalesReturnDtoPes(dto);
                return list;

            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 查看详情
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public List<SalesReturnDtoPes> GetSalesReturnShow(SalesReturnDtoPes dto)
        {
            try
            {
               var list=  _salesReturnServers.GetSalesReturnShow(dto);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 修改状态（确认订单）
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdateStateSalesReturn(PaymentDtoPes dto) {
            
        var result= await _salesReturnServers.UpdateStateSalesReturn(dto);
            return result;
        }

        /// <summary>
        /// 驳回订单
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> UpdaSalesReturn(SalesReturnDtoPes dto) {
            var result = await _salesReturnServers.UpdaSalesReturn(dto);
            return result;
        }
        /// <summary>
        /// 付款方式
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<List<PayType>>> GetPayType() { 
        var list= _salesReturnServers.GetPayType();
            return list;
        }

    }
}
